package com.foo.final_classifier;

import weka.classifiers.Evaluation;
import weka.classifiers.functions.SMO;
import weka.classifiers.functions.supportVector.RBFKernel;

import com.foo.classifiers.SVM_Classifier;
import com.foo.classifiers.SVM_Classifier_With_Options_4_1;

public class SVM_Classifier_Final_Classifier_Demo 
{
	
	private int noOfFolds = 10;
	private int noOfSeeds = 1;
	/*
	 * Classifier 1 which produces best accuracy and recall for 1000 dataset
	 * Options: Source + Title
	 */
	public Evaluation classifier1()
	{
		SVM_Classifier smo = new SVM_Classifier();
		return smo.createInstance_Source_Title(noOfFolds, noOfSeeds);
	}
	
	/*
	 * Classifier 2 which produces best precision for 1000 dataset
	 * Options: Source +  Complexity: 1.0, Kernel:RBF,FilterType:Standard
	 */
	public Evaluation classifier2()
	{
		SVM_Classifier_With_Options_4_1 smo = new SVM_Classifier_With_Options_4_1(
									1.0,SMO.FILTER_STANDARDIZE,new RBFKernel());
		return smo.createInstance_Source(noOfFolds, noOfSeeds);
	}
	/*
	 * Classifier 3 which produces best accuracy and recall for 10,000 dataset
	 * Options: Source + Title;  Complexity: 10.0, Kernel:RBF,FilterType:Normalized
	 */
	public Evaluation classifier3()
	{
		SVM_Classifier_With_Options_4_1 smo = new SVM_Classifier_With_Options_4_1(10.0,new RBFKernel());
		return smo.createInstance_Source_Title(noOfFolds, noOfSeeds);
	}
	
	/*
	 * Classifier 4 which produces best precision for 10,000 dataset
	 * Options Source;  Complexity: 5.0, Kernel:RBF,FilterType:Normalized
	 */
	public Evaluation classifier4()
	{
		SVM_Classifier_With_Options_4_1 smo = new SVM_Classifier_With_Options_4_1(5.0,new RBFKernel());
		return smo.createInstance_Source(noOfFolds, noOfSeeds);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		SVM_Classifier_Final_Classifier_Demo demo = new SVM_Classifier_Final_Classifier_Demo();
		Evaluation evaluation = demo.classifier1();
		
		StringBuilder output = new StringBuilder();
		output = new StringBuilder();
		output.append("\n*******************************************************************\n");
		output.append(
			"Classifier 1 : Building the classifier with Source + Title:");
		output.append("\nTotal Instance: " + evaluation.numInstances());
		output.append("\nPercentage of Correctly Classified Instance: " + evaluation.pctCorrect()+"%");
		output.append("\nPercentage of InCorrectly Classified Instance: " + evaluation.pctIncorrect() +"%");
		output.append("\nWeighted Precision of Classifier: " + evaluation.weightedPrecision());
		output.append("\nWeighted Recall of Classifier: " + evaluation.weightedRecall());
		output.append("\n*******************************************************************\n");
		System.out.println(output.toString());
		
		evaluation = demo.classifier2();
		
		output = new StringBuilder();
		output.append("\n*******************************************************************\n");
		output.append(
			"Classifier 2:  Building the classifier with Options: Source +  Complexity: 1.0, Kernel:RBF,FilterType:Standard:");
		output.append("\nTotal Instance: " + evaluation.numInstances());
		output.append("\nPercentage of Correctly Classified Instance: " + evaluation.pctCorrect()+"%");
		output.append("\nPercentage of InCorrectly Classified Instance: " + evaluation.pctIncorrect() +"%");
		output.append("\nWeighted Precision of Classifier: " + evaluation.weightedPrecision());
		output.append("\nWeighted Recall of Classifier: " + evaluation.weightedRecall());
		output.append("\n*******************************************************************\n");
		System.out.println(output.toString());
		
		evaluation = demo.classifier3();
		
		output = new StringBuilder();
		output.append("\n*******************************************************************\n");
		output.append(
			"Classifier 3: Building the classifier with Options: Source + Title;  Complexity: 10.0, Kernel:RBF,FilterType:Normalized");
		output.append("\nTotal Instance: " + evaluation.numInstances());
		output.append("\nPercentage of Correctly Classified Instance: " + evaluation.pctCorrect()+"%");
		output.append("\nPercentage of InCorrectly Classified Instance: " + evaluation.pctIncorrect() +"%");
		output.append("\nWeighted Precision of Classifier: " + evaluation.weightedPrecision());
		output.append("\nWeighted Recall of Classifier: " + evaluation.weightedRecall());
		output.append("\n*******************************************************************\n");
		System.out.println(output.toString());
		
		evaluation = demo.classifier4();
		output = new StringBuilder();				
		output.append("\n*******************************************************************\n");
		output.append(
			"Classifier 4: Building the classifier with Options Source;  Complexity: 5.0, Kernel:RBF,FilterType:Normalized");
		output.append("\nTotal Instance: " + evaluation.numInstances());
		output.append("\nPercentage of Correctly Classified Instance: " + evaluation.pctCorrect()+"%");
		output.append("\nPercentage of InCorrectly Classified Instance: " + evaluation.pctIncorrect() +"%");
		output.append("\nWeighted Precision of Classifier: " + evaluation.weightedPrecision());
		output.append("\nWeighted Recall of Classifier: " + evaluation.weightedRecall());
		output.append("\n*******************************************************************\n");
		System.out.println(output.toString());
	}

}
